package utils

import (
	"go-pan/internal/model"

	"github.com/gin-gonic/gin"
)

const (
	// ContextUserKey 上下文中用户信息的 key
	ContextUserKey = "user"
)

func GetUserInfo(c *gin.Context) (*model.UserInfo, bool) {
	user, exists := c.Get(ContextUserKey)
	if !exists {
		return nil, false
	}

	userInfo, ok := user.(model.UserInfo)
	if !ok {
		return nil, false
	}

	return &userInfo, true
}
